package com.ctshk.common.enums;

import java.util.Arrays;

/**
 * <p>
 * 订单退款状态枚举
 * </p>
 *
 * @author 胡广
 * @since 2021/2/26
 */
public enum OrderCancelStatus {
    UNDER_APPROVAL(1, "审批中"),
    APPROVAL_SUCCESS(2, "审批通过"),
    APPROVAL_FAIL(3, "审批不通过"),
    ALREADY_REFUND(4, "退款成功"),
    ;

    private Integer code;
    private String name;


    OrderCancelStatus(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 通过key拿预订订单状态名称
     * gzl-wansi001
     * @param code
     * @return
     */
    public static String getOrderCancelStatusName(Integer code){
        OrderCancelStatus orderCancelStatus = Arrays.stream(OrderCancelStatus.values())
                .filter(enums -> enums.getCode().equals(code)).findFirst().orElse(null);

        if(orderCancelStatus != null){
            return orderCancelStatus.getName();
        }
        return "";
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
